import { renderStart } from '@/model/type'
export const columns = context => {
  return [
    {
      prop: 'customerId',
      headCheck: '1',
      label: '客户ID'
    },
    {
      prop: 'isConsulted',
      headCheck: '1',
      label: '状态',
      width: 110,
      render: (h, row) => {
        // 是否已查阅，0否，1是
        const notyet = (
          <span>
            <span class="text-error">● 未查阅</span>
          </span>
        )
        const already = <span class="text-success">● 已查阅</span>
        return row.isConsulted === '1' ? [already] : [notyet]
      }
    },
    {
      prop: 'customerName',
      headCheck: '1',
      label: '客户名称'
    },
    {
      prop: 'customerType',
      headCheck: '0',
      label: '客户类型'
    },
    {
      prop: 'tradeType',
      headCheck: '1',
      label: '客户行业'
    },
    {
      prop: 'star',
      label: '客户级别',
      headCheck: '0',
      render: (h, row) => {
        return (
          <div class="text-warning fs16">{renderStart(row.customerStar)}</div>
        )
      }
    },
    {
      label: '客户状态',
      headCheck: '1',
      prop: 'customerStatus'
    },
    {
      prop: 'followAccountName',
      headCheck: '1',
      label: '跟进人员'
    },
    {
      prop: 'followType',
      headCheck: '1',
      label: '跟进方式'
    },
    {
      prop: 'followTime',
      headCheck: '1',
      label: '跟进时间'
    },
    {
      prop: 'customerCreateTime',
      headCheck: '0',
      label: '创建时间'
    },
    {
      prop: 'customerSource',
      headCheck: '0',
      label: '客户来源'
    },
    {
      prop: 'regionName',
      headCheck: '0',
      label: '所在地区'
    },
    {
      prop: 'customerAccountName',
      headCheck: '0',
      label: '所属业务员'
    },
    {
      prop: 'departmentName',
      headCheck: '0',
      label: '所属部门'
    },
    {
      prop: 'followPurpose',
      headCheck: '0',
      label: '跟进目的'
    },
    {
      prop: 'followTime',
      headCheck: '0',
      label: '跟进时间'
    },
    {
      prop: 'consultAccountName',
      headCheck: '0',
      label: '查阅人员'
    },
    {
      label: '内容',
      prop: 'hoverContent',
      headCheck: '1',
      width: 300,
      toolTip: true
      // render: (h, row) => {
      //   return (
      //     <div title={row.hoverContent}>{row.content}</div>
      //   //   <el-popover trigger="hover" placement="top" width="500">
      //   //     <p>{row.hoverContent}</p>
      //   //     <div slot="reference" class="name-wrapper">
      //   //       <span>{row.content}</span>
      //   //     </div>
      //   //   </el-popover>
      //   )
      // }
    },
    {
      button: true,
      label: '操作',
      headFixed: '1',
      fixed: 'right',
      width: 200,
      render: (h, row) => {
        const edit = (
          <a
            href="javascript:;"
            class="text-primary"
            onClick={() => {
              context.onEdit(row)
            }}
          >
            编辑
          </a>
        )

        const detail = (
          <a
            href="javascript:;"
            class="text-primary"
            onClick={() => {
              context.onDetail(row)
            }}
          >
            详情
          </a>
        )
        const del = (
          <a
            href="javascript:;"
            class="text-error"
            onClick={() => {
              context.onDel(row)
            }}
          >
            删除
          </a>
        )
        // 是否已查阅，0否，1是
        return context.form.tabType !== '1'
          ? [detail]
          : row.isConsulted === '0'
            ? [edit, detail, del]
            : [detail]
      }
    }
  ]
}

export const detailParams = info => {
  return [
    { name: '客户名称', label: 'customerName' },
    { name: '客户行业', label: 'tradeTypeName' },
    { name: '客户状态', label: 'customerStatusName' },
    { name: '跟进人员', label: 'followAccountName' },
    { name: '跟进方式', label: 'followTypeName' },
    { name: '跟进时间', label: 'followTime' },
    { name: '跟进内容', label: 'content', width: 'wp100' },
    { name: '查阅人员', label: 'consultAccountName' },
    { name: '提交时间', label: 'createTime' },
    { name: '提交人员', label: 'createAccountName' }
  ]
}

export const commentColumns = ctx => {
  return [
    {
      // hide: true,
      prop: 'id',
      width: 40,
      render: (h, row) => {
        return <div class="text-primary fs20">●</div>
      }
    }
  ]
}
